home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_nub_catchvolodnikov.cog < prev    next >
Text File  |  1999-11-15  |  20KB  |  812 lines

  1. # Jones 3D Cog Script
  2. #
  3. # nub_CatchVolodnikov.cog
  4. #
  5. # Nub's tomb Volodikov puzzle script
  6. #
  7. # [MDR] [TL]
  8. #
  9. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  10. # ========================================================================================
  11.  
  12. symbols
  13.     message    startup
  14.     message    aievent
  15.     message    arrivedwpnt
  16.     message    updatewpnts
  17.     message entered
  18.     message exited
  19.     message    damaged
  20.  
  21. # ************************** SUBROUTINES ************************
  22.     flex    InitDrVolodnikov        local
  23.     flex    SetWPntsRunToUpper        local
  24.     flex    SetWPntsRunToLower        local
  25.     flex    WaitAtWpnt                local
  26.     flex    RunForIt                local
  27.     flex    GiveUp                    local
  28.  
  29. # ************************** TEMPLATES **************************
  30. #    template    tplVolodnikov=volodnikov_nub    local                    #GGJ
  31.  
  32. # ************************** MISC LINKED GEOM *******************
  33.     thing    tPushBlock1
  34.     thing    tPushBlock2
  35.     thing    tPushStatue
  36.  
  37.     sector    sec_TrigInit
  38.     sector    sec_MazeEntry00                    linkid=1    mask=0x404        # Sector above hole in 2nd floor
  39.     sector    sec_MazeEntry01                    linkid=1    mask=0x404
  40.     sector    sec_MazeEntry02                    linkid=1    mask=0x404
  41.     sector    sec_MazeEntry03                    linkid=1    mask=0x404
  42.  
  43.  
  44.     sector    sec_InnerMazeEntry00            linkid=2    mask=0x404
  45.  
  46.     surface    srfBlocksWPNT0                    linkid=3    mask=0x480
  47.     surface    srfBlocksWPNT5                    linkid=3    mask=0x480
  48.     surface srfBlocksWPNT6                    linkid=3    mask=0x480
  49.     surface    srfBlocksWPNT7                    linkid=3    mask=0x480
  50.     surface srfBlocksWPNT21                    linkid=4    mask=0x480
  51.  
  52.     sector    sec_BlocksWPNT19                linkid=5    mask=0x480
  53.     sector    sec_BlocksWPNT20                linkid=5    mask=0x480
  54.  
  55. # ************************** WAYPOINTS **************************
  56.     int        n_puzzleStatus=0        local
  57.     int        b_DisabledWpnt6=0        local
  58.     int        b_StopAtWpnt13=1        local
  59.  
  60.     int        n_lastWpnt=25            local
  61.     thing    tWayPoint00
  62.     thing    tWayPoint01
  63.     thing    tWayPoint02
  64.     thing    tWayPoint03
  65.     thing    tWayPoint04
  66.     thing    tWayPoint05
  67.     thing    tWayPoint06
  68.     thing    tWayPoint07
  69.     thing    tWayPoint08
  70.     thing    tWayPoint09
  71.     thing    tWayPoint10
  72.     thing    tWayPoint11
  73.     thing    tWayPoint12
  74.     thing    tWayPoint13
  75.     thing    tWayPoint14
  76.     thing    tWayPoint15
  77.     thing    tWayPoint16
  78.     thing    tWayPoint17
  79.     thing    tWayPoint18
  80.     thing    tWayPoint19
  81.     thing    tWayPoint20
  82.     thing    tWayPoint21
  83.     thing    tWayPoint22
  84.     thing    tWayPoint23
  85.     thing    tWayPoint24
  86.     thing    tWayPoint25
  87.  
  88. # ************************** MISC LOCAL VARS *******************
  89.     thing        tVolodnikov                            #made not local GGJ
  90.     thing        tPlayer                local
  91.     thing        t_LookThing            local
  92.  
  93.     int            b_noEscape=0        local
  94.     flex        f_distDanger        local
  95.     flex        f_distZDanger        local
  96.  
  97.     int            idx                    local
  98.     int            n_ID                local
  99.     int            t_sender            local
  100.     int            t_source            local
  101.  
  102.     int            n_prevWpnt            local
  103.     int            n_crntWpnt            local
  104.     int            n_plyrWpnt            local
  105.  
  106.     int            b_RunToUpper        local
  107.     int            n_eventType            local
  108.     int            n_crntAIMode        local
  109.     int            n_param                local
  110.  
  111.     vector        vec_volod            local
  112.     vector        vec_indy            local
  113.     flex        f_val                local
  114.  
  115. # ************************** ADDITIONAL CUTSCENE VARS **********
  116.     cog            cutcog
  117.     model        mod_vo_gearhand=hand_vo_turtgear.3do    local    #GGJ
  118.  
  119.     int            push1_Blocking        local
  120.     int            push2_Blocking        local
  121.  
  122.     
  123. end
  124.  
  125.  
  126. # ========================================================================================
  127. code
  128.  
  129. # ........................................................................................
  130. startup:
  131.  
  132.     tPlayer    = GetLocalPlayerThing();
  133.     SetThingFlags(tVolodnikov, 0x80000);
  134.     
  135.     return;
  136.  
  137.  
  138. # ........................................................................................
  139. arrivedwpnt:
  140.  
  141.     if ( GetSenderRef() != tVolodnikov )
  142.         return;
  143.  
  144.     n_crntWpnt = GetParam(0);
  145.     if ( n_crntWpnt == n_prevWpnt )
  146.         return;
  147.  
  148.     AISetSubMode(tVolodnikov, 0x8000);                        # Set SUBMODE_CONTINUOUSWPNTMOTION
  149.  
  150.     if ( (n_crntWpnt == 0) || (n_crntWpnt == 5) || (n_crntWpnt == 7) )
  151.     {
  152.         if ( b_RunToUpper == 0 )
  153.         {
  154.             call SetWPntsRunToUpper;
  155.         }
  156.  
  157.         t_LookThing = tWayPoint00[6];
  158.         call WaitAtWpnt;
  159.     }
  160.  
  161.     if ( (n_crntWpnt == 21) || (n_crntWpnt == 22) )
  162.     {
  163.         n_plyrWpnt = AIFindNearestWpnt(tPlayer);
  164.         if ( n_plyrWpnt < 19 )
  165.         {
  166.             AIClearSubMode(tVolodnikov, 0x8000);            # Clear SUBMODE_CONTINUOUSWPNTMOTION
  167.             call SetWPntsRunToLower;
  168.  
  169.             t_LookThing = tWayPoint00[12];
  170.             call WaitAtWpnt;
  171.         }
  172.     }
  173.  
  174.     if ( b_RunToUpper == 1 )
  175.     {
  176.         if ( n_crntWpnt == 6 )
  177.         {
  178.             call SetWPntsRunToLower;
  179.         }
  180.         if ( (n_crntWpnt == 13) && (b_DisabledWpnt6 == 0) && (b_StopAtWpnt13 == 1) )
  181.         {
  182.             t_LookThing = tWayPoint00[12];
  183.             call WaitAtWpnt;
  184.         }
  185.     }
  186.  
  187.     n_prevWpnt = n_crntWpnt;
  188.  
  189.     return;
  190.  
  191.  
  192. # ........................................................................................
  193. updatewpnts:
  194.  
  195.     if ( (n_crntWpnt >= 12) && (n_crntWpnt <= 13) )
  196.     {
  197.         if ( GetMoveStatus(tPlayer) < 6 )
  198.         {
  199. #            DEBUGPRINT("Indy not flying\climbing up... bailing on update wpnt");
  200.             return;
  201.         }
  202.  
  203.         n_plyrWpnt = AIFindNearestWpnt(tPlayer);
  204.         if ( (n_plyrWpnt == 6) || (n_plyrWpnt == 16) )
  205.         {
  206.             call SetWPntsRunToLower;
  207.         }
  208.     }
  209.  
  210.     return;
  211.  
  212.  
  213. # ........................................................................................
  214. entered:
  215.  
  216.     t_source    = GetSourceRef();
  217.     t_sender    = GetSenderRef();
  218.     n_ID        = GetSenderID();
  219.  
  220.     if ( t_source == tPlayer )                                #---- Track current location of player
  221.     {
  222.         if ( t_sender == sec_TrigInit )
  223.         {
  224.             call InitDrVolodnikov;
  225.             return;
  226.         }
  227.  
  228.         if ( n_ID == 1 )                                        # 1st floor sector danger trigger?
  229.         {
  230.             if ( t_sender == sec_MazeEntry01 || t_sender == sec_MazeEntry02 )
  231.             {
  232. #                DEBUGPRINT("Disallowing stop at Wpnt 13");
  233.                 b_StopAtWpnt13 = 0;
  234.                 if ( n_crntWpnt == 13 )
  235.                 {
  236. #                    DEBUGPRINT("Indy near wpnt 13... flee");
  237.                     call RunForIt;
  238.                 }
  239.             }
  240.         }
  241.  
  242.         if ( n_ID == 5 )                                        # Indy + 2nd floor surface danger trigger?
  243.         {
  244.             if ( (t_sender == sec_BlocksWPNT19) || (t_sender == sec_BlocksWPNT20) )
  245.             {
  246.                 if ( n_crntWpnt >= 17 )
  247.                 {
  248.                     if ( (b_noEscape == 2) && (t_sender == sec_BlocksWPNT19) )
  249.                     {
  250.                         call GiveUp;
  251.                     }
  252.                     if ( (b_noEscape == 1) && (t_sender == sec_BlocksWPNT20) )
  253.                     {
  254.                         call GiveUp;
  255.                     }
  256.  
  257. #                    DEBUGPRINT("* Indy near wpnt 19 or 20... flee!");
  258.                     call RunForIt;
  259.                 }
  260.             }
  261.         }
  262.  
  263.         return;
  264.     }
  265.                                                             #---- Track Volodnikov
  266.     if (t_source == tVolodnikov )
  267.     {
  268.         if ( n_ID == 1 )                                        # Volod + 2nd floor sector hole in floor?
  269.         {
  270.             if ( t_sender == sec_MazeEntry00 )
  271.             {
  272.                 vec_volod = GetThingPos(tWayPoint00[6]);
  273.                 f_val = VectorZ( GetThingPos(tVolodnikov) ) - 0.06;
  274.  
  275.                 vec_volod = VectorSet( VectorX(vec_volod), VectorY(vec_volod), f_val );
  276.                 SetThingPosEx(tVolodnikov, vec_volod, FindNewSectorFromThing(tVolodnikov, vec_volod));
  277.             }
  278.  
  279.             if ( t_sender == sec_MazeEntry03 )
  280.             {
  281.                 AISetWpntRank(6, 30);
  282.             }
  283.         }
  284.  
  285.         return;
  286.     }
  287.                                                             #---- Track push blocks
  288.     if ( t_source == tPushBlock1 )
  289.     {
  290. #        DEBUGPRINT("Push Block ENTERED MSG");
  291.         if ( n_ID == 3 )                                        # Push Block + 1st floor wpnt blocker surfaces?
  292.         {
  293.             if ( t_sender == srfBlocksWPNT0 )
  294.             {
  295. #                DEBUGPRINT("Waypoint 25 Blocked");
  296.                 push1_Blocking = 25;
  297.                 AISetWpntFlags(25, 0x100);                        # set AIWPNT_DISABLED
  298.             }
  299.             else if ( t_sender == srfBlocksWPNT5 )
  300.             {
  301. #                DEBUGPRINT("Waypoint 5 Blocked");
  302.                 push1_Blocking = 23;
  303.                 AISetWpntFlags(23, 0x100);                        # set AIWPNT_DISABLED
  304.             }
  305.             else if ( t_sender == srfBlocksWPNT6 )
  306.             {
  307. #                DEBUGPRINT("Waypoint 6 Blocked");
  308.                 b_DisabledWpnt6 = 1;
  309.                 push1_Blocking = 6;
  310.                 AISetWpntFlags(6, 0x100);                        # set AIWPNT_DISABLED
  311.                 AISetWpntFlags(16, 0x100);
  312.                 AISetWpntFlags(23, 0x100);
  313.                 AISetWpntFlags(24, 0x100);
  314.                 AISetWpntFlags(25, 0x100);
  315.             }
  316.             else if ( t_sender == srfBlocksWPNT7 )
  317.             {
  318. #                DEBUGPRINT("Waypoint 7 Blocked");
  319.                 push1_Blocking = 24;
  320.                 AISetWpntFlags(24, 0x100);                        # set AIWPNT_DISABLED
  321.             }
  322.         }
  323.  
  324.         return;
  325.     }
  326.  
  327.     if ( t_source == tPushBlock2 )
  328.     {
  329. #        DEBUGPRINT("Push Block ENTERED MSG");
  330.         if ( n_ID == 3 )                                        # Push Block + 1st floor wpnt blocker surfaces?
  331.         {
  332.             if ( t_sender == srfBlocksWPNT0 )
  333.             {
  334. #                DEBUGPRINT("Waypoint 25 Blocked");
  335.                 push2_Blocking = 25;
  336.                 AISetWpntFlags(25, 0x100);                        # set AIWPNT_DISABLED
  337.             }
  338.             else if ( t_sender == srfBlocksWPNT5 )
  339.             {
  340. #                DEBUGPRINT("Waypoint 5 Blocked");
  341.                 push2_Blocking = 23;
  342.                 AISetWpntFlags(23, 0x100);                        # set AIWPNT_DISABLED
  343.             }
  344.             else if ( t_sender == srfBlocksWPNT6 )
  345.             {
  346. #                DEBUGPRINT("Waypoint 6 Blocked");
  347.                 b_DisabledWpnt6 = 1;
  348.                 push2_Blocking = 6;
  349.                 AISetWpntFlags(6, 0x100);                        # set AIWPNT_DISABLED
  350.                 AISetWpntFlags(16, 0x100);
  351.                 AISetWpntFlags(23, 0x100);
  352.                 AISetWpntFlags(24, 0x100);
  353.                 AISetWpntFlags(25, 0x100);
  354.             }
  355.             else if ( t_sender == srfBlocksWPNT7 )
  356.             {
  357. #                DEBUGPRINT("Waypoint 7 Blocked");
  358.                 push2_Blocking = 24;
  359.                 AISetWpntFlags(24, 0x100);                        # set AIWPNT_DISABLED
  360.             }
  361.         }
  362.  
  363.         return;
  364.     }
  365.  
  366.     if ( t_source == tPushStatue )                            #---- Track push statue
  367.     {
  368.         if ( n_ID == 5 )                                        # Push Statue + final escape blocker surfaces?
  369.         {
  370.             if ( t_sender == sec_BlocksWPNT19 )
  371.             {
  372. #                DEBUGPRINT("Waypoint 19 Blocked");
  373.                 AISetWpntFlags(19, 0x100);                        # set AIWPNT_DISABLED
  374.                 b_noEscape = 1;
  375.             }
  376.             else if ( t_sender == sec_BlocksWPNT20 )
  377.             {
  378. #                DEBUGPRINT("Waypoint 20 Blocked");
  379.                 AISetWpntFlags(20, 0x100);                        # set AIWPNT_DISABLED
  380.                 b_noEscape = 2;
  381.             }
  382.         }
  383.         if ( n_ID == 4 )                                        # Push Statue + final escape blocker surfaces?
  384.         {
  385.             if ( t_sender == srfBlocksWPNT21 )
  386.             {
  387. #                DEBUGPRINT("Waypoint 21 Blocked");
  388.                 AISetWpntFlags(21, 0x100);                        # set AIWPNT_DISABLED
  389.                 AIClearWpntFlags(22, 0x100);                    # clear AIWPNT_DISABLED
  390.             }
  391.  
  392. #            DEBUGFLEX(b_noEscape, "b_noEscape =");
  393.         }
  394.     }
  395.  
  396.     return;
  397.  
  398.  
  399. # ........................................................................................
  400. exited:
  401.  
  402.     t_source    = GetSourceRef();
  403.     t_sender    = GetSenderRef();
  404.     n_ID        = GetSenderID();
  405.  
  406.     if ( t_source == tPlayer )                                #---- Track current location of player
  407.     {
  408.         if ( n_ID == 1 )                                        # 1st floor sector danger trigger?
  409.         {
  410.             if ( t_sender == sec_MazeEntry01 || t_sender == sec_MazeEntry02 )
  411.             {
  412. #                DEBUGPRINT("Allowing stop at Wpnt 13");
  413.                 b_StopAtWpnt13 = 1;
  414.             }
  415.         }
  416.     }
  417.                                                             #---- Track push blocks
  418.     if ( t_source == tPushBlock1 )    
  419.     {
  420. #        DEBUGPRINT("Push Block ENTERED MSG");
  421.         if ( n_ID == 3 )                                        # Push Block + 1st floor wpnt blocker surfaces?
  422.         {
  423.             if ( t_sender == srfBlocksWPNT0 )
  424.             {
  425. #                DEBUGPRINT("Waypoint 25 Unblocked");
  426.                 AIClearWpntFlags(25, 0x100);                    # Clear AIWPNT_DISABLED
  427.             }
  428.             else if ( t_sender == srfBlocksWPNT5 )
  429.             {
  430. #                DEBUGPRINT("Waypoint 5 Unblocked");
  431.                 AIClearWpntFlags(23, 0x100);                    # Clear AIWPNT_DISABLED
  432.             }
  433.             else if ( t_sender == srfBlocksWPNT6 )
  434.             {
  435. #                DEBUGPRINT("Waypoint 6 Unblocked");
  436.                 b_DisabledWpnt6 = 0;
  437.                 AIClearWpntFlags(6, 0x100);                        # Clear AIWPNT_DISABLED
  438.                 AIClearWpntFlags(16, 0x100);
  439.  
  440.                 if ( push2_Blocking != 6 )
  441.                 {
  442.                     if ( push2_Blocking != 23 )
  443.                         AIClearWpntFlags(23, 0x100);
  444.                     if ( push2_Blocking != 24 )
  445.                         AIClearWpntFlags(24, 0x100);
  446.                     if ( push2_Blocking != 25 )
  447.                         AIClearWpntFlags(25, 0x100);
  448.                 }
  449.             }
  450.             else if ( t_sender == srfBlocksWPNT7 )
  451.             {
  452. #                DEBUGPRINT("Waypoint 7 Unblocked");
  453.                 AIClearWpntFlags(24, 0x100);                    # Clear AIWPNT_DISABLED
  454.             }
  455.  
  456.             push1_Blocking = -1;
  457.         }
  458.     }
  459.                                                             #---- Track push blocks
  460.     if ( t_source == tPushBlock2 )    
  461.     {
  462. #        DEBUGPRINT("Push Block ENTERED MSG");
  463.         if ( n_ID == 3 )                                        # Push Block + 1st floor wpnt blocker surfaces?
  464.         {
  465.             if ( t_sender == srfBlocksWPNT0 )
  466.             {
  467. #                DEBUGPRINT("Waypoint 25 Unblocked");
  468.                 AIClearWpntFlags(25, 0x100);                    # Clear AIWPNT_DISABLED
  469.             }
  470.             else if ( t_sender == srfBlocksWPNT5 )
  471.             {
  472. #                DEBUGPRINT("Waypoint 5 Unblocked");
  473.                 AIClearWpntFlags(23, 0x100);                    # Clear AIWPNT_DISABLED
  474.             }
  475.             else if ( t_sender == srfBlocksWPNT6 )
  476.             {
  477. #                DEBUGPRINT("Waypoint 6 Unblocked");
  478.                 b_DisabledWpnt6 = 0;
  479.                 AIClearWpntFlags(6, 0x100);                        # Clear AIWPNT_DISABLED
  480.                 AIClearWpntFlags(16, 0x100);
  481.  
  482.                 if ( push1_Blocking != 6 )
  483.                 {
  484.                     if ( push1_Blocking != 23 )
  485.                         AIClearWpntFlags(23, 0x100);
  486.                     if ( push1_Blocking != 24 )
  487.                         AIClearWpntFlags(24, 0x100);
  488.                     if ( push1_Blocking != 25 )
  489.                         AIClearWpntFlags(25, 0x100);
  490.                 }
  491.             }
  492.             else if ( t_sender == srfBlocksWPNT7 )
  493.             {
  494. #                DEBUGPRINT("Waypoint 7 Unblocked");
  495.                 AIClearWpntFlags(24, 0x100);                    # Clear AIWPNT_DISABLED
  496.             }
  497.  
  498.             push2_Blocking = -1;
  499.         }
  500.     }
  501.  
  502.     if ( t_source == tPushStatue )                            #---- Track push statue
  503.     {
  504.         if ( n_ID == 5 )                                        # Push Statue + final escape blocker surfaces?
  505.         {
  506.             if ( t_sender == sec_BlocksWPNT19 )
  507.             {
  508. #                DEBUGPRINT("Waypoint 19 Unblocked");
  509.                 b_noEscape = 0;
  510.                 AIClearWpntFlags(19, 0x100);                    # Clear AIWPNT_DISABLED
  511.             }
  512.             else if ( t_sender == sec_BlocksWPNT20 )
  513.             {
  514. #                DEBUGPRINT("Waypoint 20 Unblocked");
  515.                 b_noEscape = 0;
  516.                 AIClearWpntFlags(20, 0x100);                    # Clear AIWPNT_DISABLED
  517.             }
  518.         }
  519.         if ( n_ID == 4 )                                        # Push Statue + final escape blocker surfaces?
  520.         {
  521.             if ( t_sender == srfBlocksWPNT21 )
  522.             {
  523. #                DEBUGPRINT("Waypoint 21 Unblocked");
  524.                 AIClearWpntFlags(21, 0x100);                    # Clear AIWPNT_DISABLED
  525.                 AISetWpntFlags(22, 0x100);                        # set AIWPNT_DISABLED
  526.             }
  527.         }
  528.     }
  529.     
  530.     return;
  531.  
  532.  
  533. # ........................................................................................
  534. aievent:
  535.  
  536.     t_sender    = GetSenderRef();
  537.  
  538.     if ( t_sender == tVolodnikov )
  539.     {
  540.         n_eventType        = GetParam(0);
  541.         n_crntAIMode    = GetParam(1);
  542.         n_param            = GetParam(2);                            # Meaning varies according to n_eventType
  543.  
  544.         if ( BITTEST(n_eventType, 0x604) )                        # EVENT_(TOUCHED|HITWALL|HITCLIFF)?
  545.         {
  546. #            DEBUGPRINT("Hit something");
  547.             ReturnEx(1);                                        # Keep Volodnikov going
  548.         }
  549.     }
  550.  
  551.     return;
  552.  
  553.  
  554. # ........................................................................................
  555. damaged:
  556.  
  557.     return;
  558.  
  559.  
  560. # ========================================================================================
  561. #    Subroutines
  562. # ========================================================================================
  563.  
  564. # ........................................................................................
  565. InitDrVolodnikov:
  566.  
  567.     if ( n_puzzleStatus == 0 )
  568.     {
  569. #        DEBUGPRINT("** Initializing Volodnikov wpnt system.");
  570.         b_DisabledWpnt6    = 0;
  571.         b_StopAtWpnt13    = 1;
  572.  
  573.         n_prevWpnt        = 0;
  574.         n_crntWpnt        = 0;
  575.         n_plyrWpnt        = -1;
  576.  
  577.         push1_Blocking    = -1;
  578.         push2_Blocking    = -1;
  579.  
  580.         b_noEscape        = 0;                                        # Set constants
  581.         f_distDanger    = 0.80;
  582.         f_distZDanger    = 0.20;
  583.  
  584.         #tVolodnikov = CreateThing(tplVolodnikov, tWayPoint00);            #commente out and added line below, GGJ
  585.         ClearThingFlags(tVolodnikov, 0x80000);
  586.         CaptureThing(tVolodnikov);
  587.         SetThingMesh(tVolodnikov, 8, mod_vo_gearhand, 0);
  588.  
  589.         AISetInstinctWpntMode(tVolodnikov);
  590.         AISetSubMode(tVolodnikov, 0x8000);                            # Set SUBMODE_CONTINUOUSWPNTMOTION
  591.     }
  592.  
  593.     for ( idx=0; idx <= n_lastWpnt; idx = idx + 1 )                # Init waypoints
  594.     {
  595.         AISetWpnt(tWayPoint00[idx], idx);
  596.     }
  597.  
  598.     AIConnectWpnts(0, 1);
  599.     AIConnectWpnts(0, 2);
  600.     AIConnectWpnts(0, 25);
  601.     AIConnectWpnts(25, 6);
  602.     AIConnectWpnts(1, 3);
  603.     AIConnectWpnts(2, 4);
  604.     AIConnectWpnts(3, 5);
  605.     AIConnectWpnts(4, 7);
  606.     AIConnectWpnts(5, 23);
  607.     AIConnectWpnts(5, 8);
  608.     AIConnectWpnts(8, 10);
  609.     AIConnectWpnts(10, 12);
  610.     AIConnectWpnts(12, 11);
  611.     AIConnectWpnts(11, 9);
  612.     AIConnectWpnts(9, 7);
  613.     AIConnectWpnts(6, 23);
  614.     AIConnectWpnts(6, 24);
  615.     AIConnectWpnts(7, 9);
  616.     AIConnectWpnts(7, 24);
  617.  
  618.     AIConnectWpnts(12, 13);
  619.     AIConnectWpntsOneWay(13, 6);
  620.     AIConnectWpnts(13, 14);
  621.     AIConnectWpnts(14, 17);
  622.     AIConnectWpntsOneWay(16, 6);
  623.     AIConnectWpnts(17, 16);
  624.     AIConnectWpnts(17, 18);
  625.     AIConnectWpnts(17, 19);
  626.     AIConnectWpnts(19, 21);
  627.     AIConnectWpnts(19, 22);
  628.     AIConnectWpnts(21, 20);
  629.     AIConnectWpnts(22, 20);
  630.     AIConnectWpnts(20, 18);
  631.     AIConnectWpnts(18, 16);
  632.     AIConnectWpnts(18, 15);
  633.     AIConnectWpnts(15, 13);
  634.  
  635.     if ( n_puzzleStatus == 0 )
  636.     {
  637.         n_puzzleStatus = 1;
  638.  
  639.         AISetWpntFlags(22, 0x100);                            # starts out AIWPNT_DISABLED
  640.         call SetWPntsRunToUpper;
  641.     }
  642.  
  643.     return;
  644.  
  645.  
  646. # ........................................................................................
  647. SetWPntsRunToUpper:
  648.  
  649. #    DEBUGPRINT("* Setting WPnts to run up");
  650.  
  651.     b_RunToUpper    = 1;
  652.  
  653.     AISetWpntRank(0, 0);
  654.     AISetWpntRank(1, 5);
  655.     AISetWpntRank(2, 5);
  656.     AISetWpntRank(3, 5);
  657.     AISetWpntRank(4, 5);
  658.     AISetWpntRank(5, 10);
  659.     AISetWpntRank(6, 0);
  660.     AISetWpntRank(7, 10);
  661.     AISetWpntRank(8, 10);
  662.     AISetWpntRank(9, 10);
  663.     AISetWpntRank(10, 15);
  664.     AISetWpntRank(11, 15);
  665.     AISetWpntRank(12, 15);
  666.     AISetWpntRank(13, 20);
  667.     AISetWpntRank(14, 20);
  668.     AISetWpntRank(15, 20);
  669.     AISetWpntRank(16, 0);
  670.     AISetWpntRank(17, 25);
  671.     AISetWpntRank(18, 25);
  672.     AISetWpntRank(19, 30);
  673.     AISetWpntRank(20, 30);
  674.     AISetWpntRank(21, 30);
  675.     AISetWpntRank(22, 30);
  676.     AISetWpntRank(23, 5);
  677.     AISetWpntRank(24, 5);
  678.     AISetWpntRank(25, 0);
  679.  
  680.     return;
  681.  
  682.  
  683. # ........................................................................................
  684. SetWPntsRunToLower:
  685.  
  686. #    DEBUGPRINT("* Setting WPnts to run down");
  687.  
  688.     b_RunToUpper    = 0;
  689.  
  690.     AISetWpntRank(0, 30);
  691.     AISetWpntRank(1, 25);
  692.     AISetWpntRank(2, 25);
  693.     AISetWpntRank(3, 25);
  694.     AISetWpntRank(4, 25);
  695.     AISetWpntRank(5, 20);
  696.     AISetWpntRank(6, 10);
  697.     AISetWpntRank(7, 20);
  698.     AISetWpntRank(8, 20);
  699.     AISetWpntRank(9, 20);
  700.     AISetWpntRank(10, 15);
  701.     AISetWpntRank(11, 15);
  702.     AISetWpntRank(12, 15);
  703.     AISetWpntRank(13, 10);
  704.     AISetWpntRank(14, 10);
  705.     AISetWpntRank(15, 10);
  706.     AISetWpntRank(16, 15);
  707.     AISetWpntRank(17, 5);
  708.     AISetWpntRank(18, 5);
  709.     AISetWpntRank(19, 5);
  710.     AISetWpntRank(20, 5);
  711.     AISetWpntRank(21, 0);
  712.     AISetWpntRank(22, 0);
  713.     AISetWpntRank(23, 15);
  714.     AISetWpntRank(24, 15);
  715.     AISetWpntRank(25, 30);
  716.  
  717.     return;
  718.  
  719.  
  720. # ........................................................................................
  721. WaitAtWpnt:
  722.  
  723.     if ( (n_crntWpnt == 21) && (b_noEscape > 0) )
  724.     {
  725. #        DEBUGFLEX(n_crntWpnt, "WaitAtWpnt: Stopping at wpnt");
  726.         StopThing(tVolodnikov);
  727.         AIStopFlee(tVolodnikov);
  728.         AISetLookThing(tVolodnikov, t_LookThing);
  729.  
  730.         return;
  731.     }
  732.  
  733.     # Only stop if Indy isnt too close
  734.     vec_volod    = GetThingPos(tVolodnikov);
  735.     vec_indy    = GetThingPos(tPlayer);
  736.  
  737.     f_val        = VectorZ(VectorSub(vec_volod, vec_indy));
  738. #    DEBUGFLEX(f_val, "** WaitAtWpnt: Delta Z =");
  739.     if ( ABS(f_val) > f_distZDanger )
  740.     {
  741. #        DEBUGFLEX(n_crntWpnt, "** WaitAtWpnt: Stopping at wpnt");
  742.         StopThing(tVolodnikov);
  743.         AIStopFlee(tVolodnikov);
  744.         AISetLookThing(tVolodnikov, t_LookThing);
  745.  
  746.         return;
  747.     }
  748.  
  749.     f_val = VectorDist(vec_volod, vec_indy);
  750. #    DEBUGFLEX(f_val, "** WaitAtWpnt: player to volod dist = ");
  751.     if ( f_val > f_distDanger )
  752.     {
  753. #        DEBUGFLEX(n_crntWpnt, "** WaitAtWpnt: Stopping at wpnt");
  754.         StopThing(tVolodnikov);
  755.         AIStopFlee(tVolodnikov);
  756.         AISetLookThing(tVolodnikov, t_LookThing);
  757.  
  758.         return;
  759.     }
  760.  
  761. #    DEBUGFLEX(n_crntWpnt, "** WaitAtWpnt: Indy too close, not stopping.  crntWpnt =");
  762.     return;
  763.  
  764.  
  765. # ........................................................................................
  766. RunForIt:
  767.  
  768.     if ( BITTEST(GetActorFlags(tPlayer), 0x80) )            # If player has AF_INVISIBLE, do nothing
  769.         return;
  770.  
  771.     AISetSubMode(tVolodnikov, 0x8000);                        # Set SUBMODE_CONTINUOUSWPNTMOTION
  772.     AIFlee(tVolodnikov, tPlayer);
  773.  
  774.     return;
  775.  
  776.  
  777. # ........................................................................................
  778. GiveUp:
  779.  
  780.     if ( n_puzzleStatus > 1 )
  781.         return;
  782.  
  783.     n_puzzleStatus = 2;
  784.  
  785. #    PRINT("You Got Me, Indy! Here you go...take it!");
  786. #    DEBUGPRINT("You Got Me, Indy!");
  787.  
  788.     ReleaseThing(tVolodnikov);
  789.     Reset();
  790.  
  791.     DestroyThing(tVolodnikov);
  792.     tVolodnikov = -1;
  793.  
  794.     if (b_noEscape == 1)
  795.     {
  796. #        Print("south opening is blocked");
  797.         SendMessage(cutcog, user0);
  798.     }
  799.     if (b_noEscape == 2)
  800.     {
  801. #        Print("north opening is blocked");
  802.         SendMessage(cutcog, user1);
  803.     }
  804.  
  805.     return;
  806.  
  807.  
  808.  
  809. # ........................................................................................
  810. end
  811.  
  812.